#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
const int N=100000,M1=100000,M2=100000;
struct data{
	int l,r;
}edge1[M1+10],edge2[M2+10];
int n,m1,m2,i,x,y,f1[N+10],f2[N+10],fir1,fir2,pre1,pre2,ans,j;
bool flag1[M1+10],flag2[M2+10];
int min(int x,int y){
	if(x<y)return x;
	return y;
}
int max(int x,int y){
	if(x>y)return x;
	return y;
}
bool cmp(data x,data y){
	return (x.l<y.l||(x.l==y.l&&x.r<y.r));
}
int main(){
	freopen("airport.in","r",stdin);
	freopen("airport.out","w",stdout);
	scanf("%d %d %d",&n,&m1,&m2);
	for(i=1;i<=m1;++i){
		scanf("%d %d",&x,&y);
		edge1[i].l=x;
		edge1[i].r=y;
	}
	for(i=1;i<=m2;++i){
		scanf("%d %d",&x,&y);
		edge2[i].l=x;
		edge2[i].r=y;
	}
	sort(edge1+1,edge1+1+m1,cmp);
	sort(edge2+1,edge2+1+m2,cmp);
	fir1=fir2=1;
	for(i=1;i<=n;++i){
		j=1,f1[i]=f1[i-1],pre1=0;
		while(j<=m1){
			while(j<=m1&&(edge1[pre1].r>=edge1[j].l||flag1[j]))++j;
			if(j>m1)break;
			flag1[j]=true;
			++f1[i];	
			pre1=j;
		}
		j=1,f2[i]=f2[i-1],pre2=0;
		while(j<=m2){
			while(j<=m2&&(edge2[pre2].r>=edge2[j].l||flag2[j]))++j;
			if(j>m2)break;
			flag2[j]=true;
			++f2[i];
			pre2=j;
		}
	//	printf("f1[%d]=%d,f2[%d]=%d\n",i,f1[i],i,f2[i]);
	}
	for(i=0;i<=n;++i)ans=max(ans,f1[i]+f2[n-i]);
	printf("%d\n",ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
} 
